#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) Huoty, All rights reserved
# Author: Huoty <sudohuoty@163.com>
# CreateTime: 2020-06-08 20:15:34


def optimize_departments(departments, count=1):
    depm_len = len(departments)
    for _ in range(count):
        max_value_index = 0
        max_value = departments[0][1] + 1
        for i in range(0, depm_len):
            departments[i][1] += 1
            if departments[i][1] > max_value:
                max_value_index = i
                max_value = departments[i][1]
        departments[max_value_index][1] -= 4
    return departments


departments = [
    ['A', 10],
    ['B', 7],
    ['C', 5],
    ['D', 4],
]
optimize_departments(departments, 12 * 10)
print(departments)
